public class GH{
    public static void main(String[] args) {

        animal m ;
        m = new animal();
        m.speak();
        m=new dog();
        m.speak();
        m=new cat();
        m.speak();
    }
}


class animal{
    public void speak(){
        System.out.println("animal speak");
    }
}

class dog extends animal{
    public void speak(){
        System.out.println("dog speak");
    }
}

class cat extends animal{
    public void speak(){
        System.out.println("cat speak");
    }
}



